@tailwind base;
@tailwind components;
@tailwind utilities;



:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.5;
  font-weight: 400;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Milkdown 预览样式 */
.milkdown-preview {
  width: 100%;
  height: 100%;
  line-height: 1.6;
  color: #333;
}

.milkdown-preview.dark {
  color: #f3f4f6;
  background: transparent;
}

/* 标题语法 - # ## ### #### ##### ###### */
.milkdown-preview h1,
.milkdown-preview h2,
.milkdown-preview h3,
.milkdown-preview h4,
.milkdown-preview h5,
.milkdown-preview h6 {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: bold;
  margin-bottom: 1rem;
}

.milkdown-preview h1 { font-size: 2rem; }
.milkdown-preview h2 { font-size: 1.5rem; }
.milkdown-preview h3 { font-size: 1.25rem; }

/* 段落语法 */
.milkdown-preview p {
  margin-bottom: 1rem;
  line-height: 1.7;
}

/* 强调语法 - **粗体** *斜体* */
.milkdown-preview strong {
  font-weight: bold;
}

.milkdown-preview em {
  font-style: italic !important;
  font-family: inherit !important;
  font-weight: 500;
}

.milkdown-preview i {
  font-style: italic !important;
  font-family: inherit !important;
}

/* 确保所有可能的斜体标签都能正确显示 */
.milkdown-preview *[style*="italic"] {
  font-style: italic !important;
}

/* 针对markdown-it渲染的斜体 */
.milkdown-preview .emphasis {
  font-style: italic !important;
}

/* 强制所有斜体相关元素 */
.milkdown-preview em,
.milkdown-preview i,
.milkdown-preview .italic,
.milkdown-preview [data-emphasis="true"] {
  font-style: italic !important;
  font-family: inherit !important;
}

/* 添加更强的斜体样式，确保在所有情况下都能显示 */
.milkdown-preview em,
.milkdown-preview i {
  font-style: italic !important;
  font-family: inherit !important;
  transform: skew(-5deg);
  display: inline-block;
}

/* 针对嵌套的粗斜体 */
.milkdown-preview em strong,
.milkdown-preview strong em {
  font-style: italic !important;
  font-weight: bold !important;
}

/* 引用语法 - > */
.milkdown-preview blockquote {
  border-left: 4px solid #d1d5db;
  padding-left: 1rem;
  margin: 1rem 0;
  color: #6b7280;
  background: #f9fafb;
  padding: 1rem;
  border-radius: 0.25rem;
}
.milkdown-preview.dark blockquote {
  border-left-color: #4b5563;
  color: #9ca3af;
  background: #374151;
}

/* 列表语法 - - * + 和 1. 2. */
.milkdown-preview ul,
.milkdown-preview ol {
  margin: 1rem 0;
  padding-left: 2rem;
}

.milkdown-preview ul {
  list-style-type: disc;
}

.milkdown-preview ol {
  list-style-type: decimal;
}

.milkdown-preview li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

/* 嵌套列表 */
.milkdown-preview ul ul {
  list-style-type: circle;
  margin: 0.5rem 0;
}

.milkdown-preview ul ul ul {
  list-style-type: square;
}

.milkdown-preview ol ol {
  list-style-type: lower-alpha;
  margin: 0.5rem 0;
}

.milkdown-preview ol ol ol {
  list-style-type: lower-roman;
}

/* 代码语法 - `code` 和 ```code block``` */
.milkdown-preview code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: #f3f4f6;
  color: #374151;
  padding: 0.2em 0.4em;
  border-radius: 0.25rem;
  font-size: 0.95em;
  border: 1px solid #e5e7eb;
}
.milkdown-preview.dark code {
  background: #374151;
  color: #f3f4f6;
  border-color: #4b5563;
}

.milkdown-preview pre {
  background: #1f2937;
  color: #f3f4f6;
  overflow-x: auto;
  padding: 1rem;
  border-radius: 0.5rem;
  margin: 1rem 0;
  border: 1px solid #374151;
}

.milkdown-preview pre code {
  background: transparent;
  padding: 0;
  border: none;
  color: inherit;
}

/* 分隔线语法 - --- */
.milkdown-preview hr {
  border: none;
  border-top: 2px solid #e5e7eb;
  margin: 2rem 0;
}
.milkdown-preview.dark hr {
  border-top-color: #4b5563;
}

/* 链接语法 - [text](url) */
.milkdown-preview a {
  color: #2563eb;
  text-decoration: underline;
  text-decoration-color: #93c5fd;
}
.milkdown-preview.dark a {
  color: #60a5fa;
  text-decoration-color: #3b82f6;
}

.milkdown-preview a:hover {
  text-decoration-color: currentColor;
}

/* 图片语法 - ![alt](url) */
.milkdown-preview img {
  max-width: 100%;
  border-radius: 0.5rem;
  margin: 1rem 0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* 表格语法 */
.milkdown-preview table {
  border-collapse: collapse;
  width: 100%;
  border: 1px solid #e5e7eb;
  margin: 1rem 0;
}
.milkdown-preview.dark table {
  border-color: #374151;
}

.milkdown-preview th {
  background: #f9fafb;
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  font-weight: 600;
}
.milkdown-preview.dark th {
  background: #374151;
  border-color: #4b5563;
}

.milkdown-preview td {
  padding: 0.5rem;
  border: 1px solid #e5e7eb;
}
.milkdown-preview.dark td {
  border-color: #374151;
}

.milkdown-preview tr:nth-child(even) {
  background: #f9fafb;
}
.milkdown-preview.dark tr:nth-child(even) {
  background: #374151;
}

.milkdown-preview tr:hover {
  background: #f3f4f6;
}
.milkdown-preview.dark tr:hover {
  background: #4b5563;
}

/* 删除线语法 - ~~text~~ */
.milkdown-preview del {
  text-decoration: line-through;
  color: #6b7280;
}

/* 任务列表语法 - - [ ] 和 - [x] */
.milkdown-preview input[type="checkbox"] {
  margin-right: 0.5rem;
}

/* 脚注语法 */
.milkdown-preview .footnote {
  font-size: 0.875rem;
  color: #6b7280;
  border-top: 1px solid #e5e7eb;
  margin-top: 2rem;
  padding-top: 1rem;
}
.milkdown-preview.dark .footnote {
  color: #9ca3af;
  border-top-color: #4b5563;
}

/* 换行语法 */
.milkdown-preview br {
  display: block;
  margin: 0.5rem 0;
}

/* 预览模式下的编辑器样式 */
.milkdown-preview .milkdown .editor .ProseMirror {
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  outline: none;
}

/* 确保内容区域正确显示 */
.milkdown-preview .milkdown .editor .ProseMirror > * {
  margin-bottom: 1rem;
}

.milkdown-preview .milkdown .editor .ProseMirror > *:last-child {
  margin-bottom: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .milkdown-preview {
    padding: 1rem;
    font-size: 14px;
  }
  
  .milkdown-preview h1 {
    font-size: 2rem;
  }
  
  .milkdown-preview h2 {
    font-size: 1.5rem;
  }
}

.milkdown-preview .milkdown {
  @apply w-full h-full;
}

.milkdown-preview .milkdown .editor {
  @apply w-full h-full;
}

/* 自定义滚动条样式 */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background-color: #D1D5DB;
  border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background-color: #9CA3AF;
}

/* 深色模式滚动条 */
.dark .custom-scrollbar::-webkit-scrollbar-thumb {
  background-color: #4B5563;
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background-color: #6B7280;
}

/* Firefox 滚动条 */
.custom-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: #D1D5DB transparent;
}

.dark .custom-scrollbar {
  scrollbar-color: #4B5563 transparent;
}

/* 编辑器特殊样式 */
.editor-textarea {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
  line-height: 1.6;
  tab-size: 2;
}

.editor-textarea:focus {
  outline: none;
  box-shadow: none;
}

/* 预览区域美化 */
.preview-container {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.dark .preview-container {
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.05) 100%);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* 工具栏按钮悬停效果 */
.toolbar-button {
  position: relative;
  overflow: hidden;
}

.toolbar-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.toolbar-button:hover::before {
  left: 100%;
}

/* 加载动画 */
@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
  }
  50% {
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.8);
  }
}

.pulse-glow {
  animation: pulse-glow 2s ease-in-out infinite;
}

/* 渐变文字效果 */
.gradient-text {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* 卡片悬停效果 */
.hover-card {
  transition: all 0.3s ease;
}

.hover-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.dark .hover-card:hover {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* 按钮点击波纹效果 */
.ripple-button {
  position: relative;
  overflow: hidden;
}

.ripple-button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.3s, height 0.3s;
}

.ripple-button:active::after {
  transform: scale(0);
  opacity: 0;
  transition: 0s;
}

/* Toast 淡出动画 */
@keyframes fadeOut {
  0% {
    opacity: 1;
    filter: blur(0px);
    transform: translateY(0) scale(1);
  }
  50% {
    opacity: 0.7;
    filter: blur(1px);
    transform: translateY(-5px) scale(0.98);
  }
  100% {
    opacity: 0;
    filter: blur(3px);
    transform: translateY(-10px) scale(0.95);
  }
}

/* 确保toast动画正常工作 */
[data-sonner-toast] {
  animation-fill-mode: forwards;
}

/* markdown 预览区表格自适应宽度样式 */
.markdown-preview table {
  table-layout: auto;
  min-width: 0;
  width: 100%;
}
.markdown-preview th, .markdown-preview td {
  word-break: break-all;
  padding: 4px 8px;
  border: 1px solid #ddd;
}